package com.ldkj.panzh.controller;

import com.ldkj.panzh.domain.AjaxResult;
import com.ldkj.panzh.domain.TableDataInfo;
import com.ldkj.panzh.param.DoorSearchParam;
import com.ldkj.panzh.service.DoorAccessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DoorAccessController extends BaseController {

    @Autowired
    DoorAccessService doorAccessService;

    /**
     * 查询门禁点列表
     *
     * @param doorSearchParam 查询参数
     * @return 门禁列表数据
     * @throws Exception
     */
    @RequestMapping("/queryDoorStates")
    @ResponseBody
    public TableDataInfo queryDoorStates(@RequestBody DoorSearchParam doorSearchParam) throws Exception {
        return getDataTable(doorAccessService.queryDoorStates(doorSearchParam));
    }

    /**
     * 查询门禁数量和状态统计
     *
     * @param doorSearchParam 查询参数
     * @return 统计数据（总数、在线数、离线数、开启数、关闭数、异常数等）
     * @throws Exception
     */
    @RequestMapping("/queryDoorStats")
    @ResponseBody
    public AjaxResult queryDoorStats(@RequestBody DoorSearchParam doorSearchParam) throws Exception {
        return success(doorAccessService.queryDoorStats(doorSearchParam));
    }

}
